package com.jiefeng.manager.service.impl;

import com.jiefeng.dao.MerchantMapper;
import com.jiefeng.manager.queryRequest.MerchantRequest;
import com.jiefeng.manager.service.MerchantService;
import com.jiefeng.manager.table.MerchantInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by hts on 2016/6/26.
 */
@Service
public class MerchantServiceImpl implements MerchantService {

    private final Logger logger = LoggerFactory.getLogger(MerchantServiceImpl.class);

    @Autowired
    private MerchantMapper merchantMapper;

    @Override
    public int addMerchant(MerchantInfo merchantInfo) {
        return merchantMapper.insert(merchantInfo);
    }

    @Override
    public int updateMerchant(MerchantInfo merchantInfo) {
        return merchantMapper.update(merchantInfo);
    }

    @Override
    public List<MerchantInfo> getListByPage(MerchantRequest merchantRequest) {
        return merchantMapper.getListByPage(merchantRequest);
    }

    @Override
    public MerchantInfo getMerchantById(String id) {

        MerchantRequest request = new MerchantRequest();
        request.setId(Integer.parseInt(id));
        return merchantMapper.get(request);
    }

    @Override
    public int getCount(MerchantRequest merchantRequest) {
        return merchantMapper.getCount(merchantRequest);
    }

    @Override
    public long countbyParam(Map<String, String> param) {
        return 0;
    }

    @Override
    public void deleteMerchant(String merchantId) {
        merchantMapper.deleteByMerchantId(merchantId);
    }
}
